<template>
  <div>
    <Header :left="true" leftText="返回" title="加严管控详情" />

    <!-- 滑动区域，适应手机分辨率 -->
    <div class="textScroll">
      <div class="divMessage">
        <!-- <Field
          v-model="addStrictManage.FactoryID"
          :readonly="true"
          size="small"
          class="Field"
          center
          colon
          label="工厂"
        /> -->
        <van-row style="margin-left: 10px; margin-top: 10px">
          <van-col span="6"><b>生产线:</b></van-col>
          <van-col span="14">{{
            showPLineIDName(addStrictManage.PLineID)
          }}</van-col>
        </van-row>

        <van-row style="margin-left: 10px; margin-top: 10px">
          <van-col span="6"><b>加严类型:</b></van-col>
          <van-col span="14">{{
            showAddStrictTypeName(addStrictManage.StrictTypeID)
          }}</van-col>
        </van-row>
        <van-row style="margin-left: 10px; margin-top: 10px">
          <van-col span="6"><b>建议等级:</b></van-col>
          <van-col span="14">{{
            showABCTypeName(addStrictManage.ABCType)
          }}</van-col>
        </van-row>
      </div>
      <!-- 基本信息 -->
      <van-row style="margin-top: 10px">
        <van-col>
          <van-image
            width="40"
            height="30"
            style="margin-left: -10px"
            src="assets/block.png"
          />
        </van-col>
        <van-col class="message" style="margin-top: 5px">基本信息</van-col>
      </van-row>
      <div class="divMessage">
        <van-row style="margin-left: 10px; margin-top: 10px">
          <van-col span="6"><b>加严开始时间:</b></van-col>
          <van-col span="14">{{ addStrictManage.FromDatetime }}</van-col>
        </van-row>
        <van-row style="margin-left: 10px; margin-top: 10px">
          <van-col span="6"><b>生产订单:</b></van-col>
          <van-col span="14">{{
            showPOrderIDName(addStrictManage.POrderID)
          }}</van-col>
        </van-row>

        <van-row style="margin-left: 10px; margin-top: 10px">
          <van-col span="6"><b>加严说明:</b></van-col>
          <van-col span="14">{{ addStrictManage.StrictDescription }}</van-col>
        </van-row>
      </div>
      <!-- 主管审核 -->
      <van-row style="margin-top: 10px">
        <van-col>
          <van-image
            width="40"
            height="30"
            style="margin-left: -10px"
            src="assets/block.png"
          />
        </van-col>
        <van-col class="message" style="margin-top: 5px">判定复核</van-col>
      </van-row>
      <div class="divMessage">
        <van-row style="margin-left: 10px; margin-top: 10px">
          <van-col span="6"><b>复核人:</b></van-col>
          <van-col span="14">{{ addStrictManage.ComfirmMan }}</van-col>
        </van-row>
        <van-row style="margin-left: 10px; margin-top: 10px">
          <van-col span="6"><b>复核时间:</b></van-col>
          <van-col span="14">{{ addStrictManage.ComfirmDatetime }}</van-col>
        </van-row>
        <van-row style="margin-left: 10px; margin-top: 10px">
          <van-col span="6"><b>复核备注信息:</b></van-col>
          <van-col span="14">{{ addStrictManage.ComfirmMemo }}</van-col>
        </van-row>
        <van-row style="margin-left: 10px; margin-top: 10px">
          <van-col span="6"><b>已判定复核:</b></van-col>
          <van-col span="14">{{ valueComfirmed }}</van-col>
        </van-row>
      </div>
      <van-row style="margin-top: 10px">
        <van-col>
          <van-image
            width="40"
            height="30"
            style="margin-left: -10px"
            src="assets/block.png"
          />
        </van-col>
        <van-col class="message" style="margin-top: 5px">确认审核</van-col>
      </van-row>
      <div class="divMessage">
        <van-row style="margin-left: 10px; margin-top: 10px">
          <van-col span="6"><b>审核人:</b></van-col>
          <van-col span="14">{{ addStrictManage.CheckeMan }}</van-col>
        </van-row>
        <van-row style="margin-left: 10px; margin-top: 10px">
          <van-col span="6"><b>审核时间:</b></van-col>
          <van-col span="14">{{ addStrictManage.CheckeDatetime }}</van-col>
        </van-row>
        <van-row style="margin-left: 10px; margin-top: 10px">
          <van-col span="6"><b>审核备注信息:</b></van-col>
          <van-col span="14">{{ addStrictManage.CheckeMemo }}</van-col>
        </van-row>
        <van-row style="margin-left: 10px; margin-top: 10px">
          <van-col span="6"><b>已确认审核:</b></van-col>
          <van-col span="14">{{ valueChecked }}</van-col>
        </van-row>
      </div>
    </div>
  </div>
</template>
<script>
import {
  Icon,
  NoticeBar,
  Button,
  Row,
  Tag,
  Checkbox,
  Pagination,
  popup,
  Loading,
  Popup,
  Panel,
  ImagePreview,
  Toast,
  tab,
  tabs,
  Divider,
  Image as VanImage,
  Field,
  CellGroup,
  Cell,
  Picker,
  Uploader,
  Dialog,
  Col,
  RadioGroup,
  Radio,
} from "vant";
import { _httpClient as _httpClientApi } from "@/libs/api";
import { _httpClient } from "@/libs/apisie";
import { storage } from "@/libs/utils";
import {
  removeToken,
  getToken,
  setBaseApiFrefix,
  getBaseApiFrefix,
} from "@/libs/auth";
Vue.use(Cell);
Vue.use(CellGroup);
Vue.use(tab);
Vue.use(tabs);
Vue.use(Button);
Vue.use(Col);
Vue.use(Row);
Vue.use(Icon);
Vue.use(VanImage);
Vue.use(Divider);
Vue.use(Checkbox);
Vue.use(Pagination);
Vue.use(Panel);
Vue.use(Dialog);
Vue.use(Picker);
Vue.use(popup);
Vue.use(Uploader);
Vue.use(Loading);
Vue.use(Field);
Vue.use(RadioGroup);
Vue.use(Radio);
import Header from "@/components/header.vue";
import apicloud from "@/libs/apicloud";
export default {
  name: "heyu2",

  components: {
    Button,
    NoticeBar,
    Header,
    ImagePreview,
    Icon,
    Row,
    tab,
    popup,
    Popup,
    tabs,
    Tag,
    VanImage,
    Toast,
    Divider,
    Field,
    CellGroup,
    Cell,
    Uploader,
    Picker,
    Dialog,
    Col,
    RadioGroup,
    Radio,
  },

  data() {
    return {
      columnsPOrderID: [],
      btnLoading: false,
      winName: "", //窗口名
      user: [], //当前登录用户
      columnsPLineID: [],
      columnsStrictTypeID: [
      { StrictTypeID: "SM01", StrictTypeName: "关键工艺参数异常加严" },
        { StrictTypeID: "SM02", StrictTypeName: "机器设备异常加严" },
        { StrictTypeID: "SM03", StrictTypeName: "质量异常加严" },
        { StrictTypeID: "SM04", StrictTypeName: "生产条件异常加严" },
      ],
      columnsABCType: [
        { ABCType: "1", ABCTypeName: "甲" },
        { ABCType: "2", ABCTypeName: "乙" },
        { ABCType: "3", ABCTypeName: "丙" },
        { ABCType: "4", ABCTypeName: "-未确定" },
      ],
      form: [],
      faultTypes: [],
      stopReson: [],
      uploadSuccess: false,
      columnsDealType: [],
      columnsEmployee: [],
      columnsQProblem: [],
      columnsshift: [],
      showPickerEmployee: false,
      showPickerQProblem: false,
      item: {},
      valuepDealTypeName: "",
      EmployeeName: "",
      time: "",
      FactoryID: "",
      valuepShiftName: "",
      CheckTypeName: "",
      QProblemName: "",
      valueteamid: "",
      nowDate: "",
      EmployeeID: "",
      result: [],
      //领班
      QCLeaderAgreeValue: "",
      //带版主管
      TeamLeaderAgreeValue: "",
      //质量负责人
      QCManagerAgreeValue: "",
      //生产部门负责人
      PrdManagerAgreeValue: "",
      //利润点负责人
      FactoryManagerAgreeValue: "",
      //当前状态
      status: "",
      //是否显示人员
      showEmployee: false,
      addStrictManage: {},
      valueComfirmed: "",
      valueChecked: "",
    };
  },
  created: function () {
    this.user = JSON.parse(storage.get("user"));
    let oldHight = api.winWidth;
    this.screenWidth = oldHight;
    this.form = api.pageParam.item;
    this.nowDate = this.getNowTime();
    this.getAddStrictManage();
    this.getPline();
    this.getPOrderID();
  },
  methods: {
    showABCTypeName(ABCType) {
      var ABCTypeName = ABCType;
      this.columnsABCType.forEach((item) => {
        if (item.ABCType === ABCType) {
          ABCTypeName = item.ABCTypeName;
        }
      });
      return ABCTypeName;
    },
    showPLineIDName(PLineID) {
      var PLineName = PLineID;
      this.columnsPLineID.forEach((item) => {
        if (item.PLineID === PLineID) {
          PLineName = item.PLineName;
        }
      });
      return PLineName;
    },

    showAddStrictTypeName(AddStrictType) {
      var AddStrictTypeName = AddStrictType;
      this.columnsStrictTypeID.forEach((item) => {
        if (item.StrictTypeID === AddStrictType) {
          AddStrictTypeName = item.StrictTypeName;
        }
      });
      return AddStrictTypeName;
    },
    showPOrderIDName(POrderID) {
      var POrderIDName = POrderID;
      this.columnsPOrderID.forEach((item) => {
        if (item.POrderID === POrderID) {
          POrderIDName = item.POrderIDAndMaterialName;
        }
      });
      return POrderIDName;
    },
    async getPOrderID() {
      let _this = this;
      try {
        let res = await _httpClient.get(
          _httpClient.getApiPrefix() + "/MachineCurrentPOrder/GetList"
        );
        if (res.HttpCode === "200") {
          let teamMap = res.Data.map((item) => ({
            POrderID: item.POrderID,
            MaterialName: item.MaterailName,
            MaterialID: item.MaterailID,
            POrderIDAndMaterialName: item.POrderID + " " + item.MaterailName,
          }));
          _this.columnsPOrderID = teamMap;
        }
      } catch (e) {
        Toast.fail(JSON.stringify(e));
      }
    },
    //获取生产线
    async getPline() {
      let _this = this;
      try {
        let res = await _httpClient.get(
          _httpClient.getApiPrefix() + "/PLineEquipment/GetList?FactoryID=TC00"
        );
        if (res.HttpCode === "200") {
          let teamMap = res.Data.map((item) => ({
            PLineID: item.PLineID,
            PLineName: item.PLineName,
          }));
          _this.columnsPLineID = teamMap;
        }
      } catch (e) {
        Toast.fail(JSON.stringify(e));
      }
    },

    async getAddStrictManage() {
      let _this = this;
      Toast.loading({
        mask: true,
        forbidClick: true,
        duration: 0,
        message: "Loading...",
      });
      try {
        let res = await _httpClient.get(
          _httpClient.getApiPrefix() +
            "/AddStrictManage/GetEntity?id=" +
            this.form.AddStrictID
        );
        // if (res.Total == 0) {
        //   Toast.clear();
        // } else {
        Toast.clear();
        _this.addStrictManage = res.Data;
        if (_this.addStrictManage.Comfirmed) {
          this.valueComfirmed = "是";
        } else {
          _this.valueComfirmed = "否";
        }

        if (_this.addStrictManage.Checked) {
          this.valueChecked = "是";
        } else {
          _this.valueChecked = "否";
        }
        //}
      } catch (e) {
        Toast.fail(JSON.stringify(e));
      }
    },
    // 获取当前时间
    getNowTime() {
      let dateTime;
      let yy = new Date().getFullYear();
      let mm = new Date().getMonth() + 1;
      let dd = new Date().getDate();
      let hh = new Date().getHours();
      let mf =
        new Date().getMinutes() < 10
          ? "0" + new Date().getMinutes()
          : new Date().getMinutes();
      let ss =
        new Date().getSeconds() < 10
          ? "0" + new Date().getSeconds()
          : new Date().getSeconds();
      dateTime = yy + "-" + mm + "-" + dd + " " + hh + ":" + mf + ":" + ss;
      return dateTime;
    },
  },
};
</script>
<style>
body {
  background-color: White;
}

.pic {
  width: 100%;
  text-align: center;
}

.clickbtn {
  width: 1;
  margin: 5px 10px;
  line-height: 45px;
  border: 1px #ccc dashed;
  text-align: center;
}

.buttonColor {
  background-color: #ff9933;
  border-color: #ff9933;
}

.buttonColor2 {
  background-color: #1076c0;
  border-color: #1076c0;
}

.message {
  font-size: 15px;
  margin-top: 5px;
  margin-left: -10px;
  font-weight: bold;
}

.divStyle {
  border: 1px solid #dcdcdc;
  border-top-width: 3px;
  border-left-width: 3px;
  margin-left: 5px;
  margin-right: 4px;
  margin-top: 4px;
}

.pagination {
  position: fixed;
  bottom: 15px;
  width: 300px;
  margin-left: 10%;
  color: rgb(0, 0, 255);
  text-align: center;
}

.divMedia {
  margin-top: 0px;
  height: 230px;
  border: solid #dcdcdc;
  margin-left: 5px;
  margin-right: 15px;
  border-top-width: 4px;
  border-left-width: 4px;
  border-right-width: 1px;
  border-bottom-width: 1px;
}

.divMedia2 {
  margin-top: 0px;
  height: 160px;
  border: solid #dcdcdc;
  margin-left: 5px;
  margin-right: 15px;
  border-top-width: 4px;
  border-left-width: 4px;
  border-right-width: 1px;
  border-bottom-width: 1px;
}

.button {
  position: fixed;
  left: 5px;
  right: 5px;
  bottom: 24px;
  width: 100%;
  height: 30px;
  font-size: 12px;
}

.divMessage {
  margin-top: 0px;
  border: solid #dcdcdc;
  margin-left: 5px;
  margin-right: 15px;
  border-top-width: 4px;
  border-left-width: 4px;
  border-right-width: 1px;
  border-bottom-width: 1px;
}

.Field {
  font-weight: bold;
  font-size: 15px;
  color: #9c8e8e;
  height: 45px;
}

.Field1 {
  font-weight: bold;
  font-size: 15px;
  color: #9c8e8e;
  height: 90px;
}

.textScroll {
  display: inline-block;
  position: fixed;
  top: 5rem;
  bottom: 0rem;
  overflow: scroll;
  right: 0;
  width: 100%;
  z-index: 1;
}
</style>
